<include file="common/hearder"/>

<h4>-------权限管理-------</h4>
<form method="post">
    <?php foreach($menu_list as $v){?>
    <?php if($v['pmid']==0){?>
    <ul>
        <li>
            <input type="checkbox" class="check_all" name="mids[]" value="<?php echo $v['mid']; ?>" <?php echo empty($auth_list[$v['mid']])?'':'checked'; ?> /><?php echo $v['name']; ?>
            <ul>
                <li>
                    <?php foreach($menu_list as $m){?>
                    <?php if($m['pmid']==$v['mid']){?>
                    <input type="checkbox" class="check_a" name="mids[]" value="<?php echo $m['mid']; ?>" <?php echo empty($auth_list[$m['mid']])?'':'checked'; ?> /><?php echo $m['name']; ?>
                    <ul>
                        <?php foreach($menu_list as $ml){?>
                        <?php if($ml['pmid']==$m['mid']){?>
                        <input type="checkbox" class="check_a" name="mids[]" value="<?php echo $ml['mid']; ?>" <?php echo empty($auth_list[$ml['mid']])?'':'checked'; ?> /><?php echo $ml['name']; ?>
                        <?php }}?>
                    </ul>
                    <?php }}?>
                </li>
            </ul>
        </li>
    </ul>
    <?php }}?>
    <input type="hidden" value="1" name="submit">
    <input type="hidden" value="{$_GET['pt_id']}" name="pt_id">
    <button type="submit" class="btn btn-info">修改权限</button>
    <a href="{:U('index')}" class="btn btn-default">返回上一页</a>
</form>
<script>
    <!--  全选和反选prop(); prop()方法设置或返回被选元素的属性和值-->
    $('.check_all').on('click',function () {
        if($(this).prop('checked')){
            $(this).next().find('.check_a').each(function () {
                if($(this).prop('checked')){
                    $(this).prop('checked',false);
                }else{
                    $(this).prop('checked',true);
                }
            });
        }else{
            $(this).next().find('.check_a').prop('checked',false);
        }
    });
</script>
<include file="common/footer"/>